package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbContentMapper;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.TbContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class TbContentServiceImpl implements TbContentService {

    @Autowired
    private TbContentMapper tbContentMapper;

    @Override
    public List<TbContent> getContentList() {
        List<TbContent> list = tbContentMapper.getContentList();
        return list;
    }

    @Override
    public void insertContentInfo(TbContent tbContent) {
        tbContentMapper.insertSelective(tbContent);
    }

    @Override
    public TbContent updateContent(Long id) {
        return tbContentMapper.selectByPrimaryKey(id);
    }

    @Override
    public void deleteContent(Long id) {
        tbContentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateContentInfo(TbContent tbContent) {
        tbContentMapper.updateByPrimaryKeySelective(tbContent);
    }

    @Override
    public List<TbContent> getContentInfo(Integer obj) {
        //轮播图
        if(obj==1){
            List<TbContent> list = tbContentMapper.selectBanner();
            return list;
        }
        //今日推荐
        if(obj==2){
            List<TbContent> list = tbContentMapper.selectToday();
            return list;
        }
        //猜你喜欢
        if(obj==3){
            List<TbContent> list = tbContentMapper.selectLike();
            return list;
        }
        //有趣
        if(obj==4){
            List<TbContent> list = tbContentMapper.selectFun();
            return list;
        }
        //楼层
        if(obj==5){
            List<TbContent> list = tbContentMapper.selectFloat();
            return list;
        }
        return null;
    }
}
